package com.ccys.cms.controller.consultation;

import com.ccys.cms.service.consultation.AppointmentCancellationWebService;
import com.ccys.common.constants.ContextConstants;
import com.ccys.common.util.Kit;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.consultation.AppointmentCancellationDTO;
import com.ccys.db.entity.TblAppointmentCancellation;
import com.ccys.db.vo.consultation.AppointmentCancellationWebVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@Api(tags = "诊断与预约-appointment_cancellation")
@RequestMapping("consultation")
public class AppointmentCancellationWebController {

    @Autowired
    private AppointmentCancellationWebService appointmentCancellationWebService;

    @GetMapping("appointmentCancellation")
    @ApiOperation("获取列表")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "clinicId", value = "clinicId", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "companyId", value = "companyId", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "status", value = "status", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "name", value = "name", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "type", value = "1in-clinic 2online 3textbased", required = false, dataType = "string", paramType = "query"),

        @ApiImplicitParam(name = "id", value = "对象id", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "startTime", value = "开始时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "endTime", value = "结束时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "orderByStr", value = "排序字段（后端返回的字段  asc升序，desc 降序,加上end后缀。示例（createdOn降序排 则传值 createdOn descend））",paramType = "query"),
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = AppointmentCancellationWebVO.class)
    })
    public ResponseResult listObjectsCms(HttpServletRequest request, HttpServletResponse response, @ApiIgnore AppointmentCancellationDTO dto) {
        return this.appointmentCancellationWebService.listObjectsCms(request, response, dto);
    }



    @PostMapping("appointmentCancellation")
    @ApiOperation("添加")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "status", value = "status", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "clinicId", value = "clinicId", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "companyId", value = "companyId", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "hour", value = "hour", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "name", value = "name", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "policy", value = "policy", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "type", value = "1in-clinic 2online 3textbased", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult save(@ApiIgnore TblAppointmentCancellation entity) {
        entity.setId(null);
        return this.appointmentCancellationWebService.change(entity);
    }


    @PutMapping("appointmentCancellation")
    @ApiOperation("编辑")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "status", value = "status", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "id", value = "ID号", required = true, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "clinicId", value = "clinicId", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "companyId", value = "companyId", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "hour", value = "hour", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "name", value = "name", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "policy", value = "policy", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "type", value = "1in-clinic 2online 3textbased", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult edit(@ApiIgnore TblAppointmentCancellation entity) {
        Kit.allParamValid(entity, "id");
        return this.appointmentCancellationWebService.change(entity);
    }


    @DeleteMapping("appointmentCancellation")
    @ApiOperation("删除")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "ID号", required = true, dataType = "string", paramType = "query")
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult delete(@ApiIgnore TblAppointmentCancellation dto) {
        Kit.allParamValid(dto, "id");
        return this.appointmentCancellationWebService.delete(dto);
    }

}